package com.gitee.wsl.io.binary

import com.gitee.wsl.ext.array.readFloatLE
import com.gitee.wsl.ext.array.writeFloatLE

/**
 * The binary data type for a float.
 */
object FloatData : BinaryData<Float> {
    override val size: Int = Float.SIZE_BYTES
    override fun parseLE(array: ByteArray, offset: Int): Float {
        //return IntData.parseLE(array, offset).toFloat()
//        val bits = IntData.parseLE(array, offset)
//        println("parse bits:$bits")
//        return Float.fromBits( bits)
        return array.readFloatLE(offset)
    }

    override fun storeLE(value: Float, array: ByteArray, offset: Int) {
        array.writeFloatLE(value,offset)
        //IntData.storeLE(value.toRawBits(), array, offset)
//        val bits = value.toRawBits()
//        println("store bits:$bits")
//        IntData.storeLE(bits, array, offset)
    }
}
